<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('labor_blacks', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->default(0)->index();
            $table->unsignedBigInteger('labor_id');  // 劳务人员ID
            $table->string('reason')->nullable();      // 拉黑原因
            $table->dateTime('start_date');          // 拉黑开始时间
            $table->dateTime('end_date')->nullable(); // 拉黑结束时间（可为空表示永久）
            $table->unsignedBigInteger('admin_id')->nullable(); // 创建人ID
            $table->timestamps();
            // 添加索引和外键约束
            $table->index('labor_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('labor_blacks');
    }
};
